package edu.fzu.crud.controller;

import edu.fzu.crud.bean.Department;
import edu.fzu.crud.common.Result;
import edu.fzu.crud.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author JohnCarraway
 * @create 2020-12-03 0:48
 */
@Controller
public class DepartmentController {

    @Autowired
    public DepartmentService departmentService;

    //返回所有部门信息

    @ResponseBody
    @RequestMapping("/getDeptInfo")
    public Result getDepts(){
        List<Department> list = departmentService.getDepts();
        return Result.success().add("depts", list);
    }
}
